package com.ddm.service.impl;

import com.ddm.mapper.BookDetailMapper;
import com.ddm.service.IBookDetailService;
import com.entity.BookDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by he on 2025/3/23 17:15
 */
@Service
public class BookDetailServiceImpl implements IBookDetailService {
    // 定义BookDetailMapper对象
    @Autowired
    private BookDetailMapper bookDetailMapper;


    // 根据bookDetailId查询订单详情
    @Override
    public BookDetail selectBookDetailById(Integer bookDetailId) {
        return bookDetailMapper.selectByBookDetailId(bookDetailId);
    }

    // 根据bookDetailId删除订单详情
    @Override
    public int deleteBookDetailById(Integer bookDetailId) {
        return bookDetailMapper.deleteByBookDetailId(bookDetailId);
    }

    // 新增订单详情
    @Override
    public int insertBookDetail(List<BookDetail> bookDetails) {
        for (BookDetail bookDetail : bookDetails)
            bookDetailMapper.insert(bookDetail);
        return bookDetails.size();
    }

    @Override
    public List<BookDetail> selectBookDetailList(BookDetail bookDetail) {
        return bookDetailMapper.selectBookDetailList(bookDetail);
    }
}
